#pragma once
#include <QWidget>
#include <memory>
#include <thread>
#include <qmutex.h>
#include <qqueue.h>
#include <qevent.h>
#include <vector>
#ifdef ENABLE_LIB_MEDIA
#include "mf_camera_capturer.h"
#include "mf_camera_capturer_params.h"
#include "ffmpeg_stream.h"
#include "ffmpeg_decoder.h"
#include "ffmpeg_helper.h"
#include "ffmpeg_d3d_decoder.h"
#include "d3d11_renderer.h"
#endif

using namespace HSDK;

namespace Ui {
    class CameraPreviewerWidget;
}

class CameraPreviewerWidget : public QWidget
{
    Q_OBJECT

public:
    explicit CameraPreviewerWidget(QWidget* parent = nullptr);
    ~CameraPreviewerWidget();

    void init_ctrl();

protected:
    void paintEvent(QPaintEvent*);

private slots:
    void slot_btn_open();
    void slot_btn_close();
    void slot_cbx_index_changed(int index);

signals:
    void sign_decoded_frame(std::shared_ptr<AVFrame> frame);
    

private:
    Ui::CameraPreviewerWidget* ui;

    std::shared_ptr<D3D11Renderer> d3d_renderer_;
    MFCameraCapturer::shared capturer_;

    std::vector<MFCameraDevice::shared> devices_;
};